using System;
using Libs.LEvent;
namespace Client.Hotfix
{
    [UGFM(UGFMWeight.EventService)]
    public class EventService : IAwake, IUpdate, IDestroy
    {
        private LEvents<int> events;
        public void Awake()
        {
            events = new();
            this.Log("EventService is running");
        }

        public void Update()
        {
            events?.Tick();
        }
        public void Destroy()
        {
            events?.Destroy();
            events = null;
        }

        public void AddListener(int key, Action<object> callBackHandle)
        {
            events.AddListener(key, callBackHandle);

        }

        public void RemoveListenerByKey(int key)
        {
            events.RemoveListenerByKey(key);
        }

        public void RemoveListenerByClass(object target)
        {
            events.RemoveListenerByTarget(target);
        }



    }

}
